﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using DOTNETGROUP.Entities;
using DOTNETGROUP.Data;

public partial class Controls_ControlVideoLeft : System.Web.UI.UserControl
{

    AccordionPane pn;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindingTourToAcr();
        }
    }
    Literal lbTitle;
    Literal lbContent;
    private void BindingTourToAcr()
    {
        int TotalRows = 0;

        // Get ID của tour độc đáo
        TList<LoaiVideo> TList_LoaiVideo = DataRepository.LoaiVideoProvider.GetPaged("TrangThai = 1", "Id", 0, 0, out TotalRows);

        string strHTML_Header = "";
        string strHTML_Content = "";
        if (TList_LoaiVideo.Count > 0)
        {
            for (int i = 0; i < TList_LoaiVideo.Count; i++)
            {
                lbTitle = new Literal();
                lbContent = new Literal();
                strHTML_Header = "";
                strHTML_Header = "<div class='accor_left'>";
                strHTML_Header += "<font style='padding-left: 15px;'>" + TList_LoaiVideo[i].TenLoaiVideo + "</font></div>";
                lbTitle.Text = strHTML_Header;
                TList<Video> TList_Video = DataRepository.VideoProvider.Find("IdLoaiVideo = " + TList_LoaiVideo[i].Id);
                if (TList_Video.Count > 0)
                {
                    for (int j = 0; j < TList_Video.Count; j++)
                    {
                        strHTML_Content = "";
                        strHTML_Content += "<img src='" + ResolveUrl("../Images/dotnetgroup/youtube.png") + "' style='margion-right: 5px;' align='left' /><a href='" + ResolveUrl("../Video/" + GetTieuDe(TList_Video[j].TieuDe)) + "_" + TList_Video[j].Id + ".aspx'>" + TList_Video[j].TieuDe + "</a><br/>";
                    }
                }
                else
                {
                    strHTML_Content = "Chưa cập nhật dữ liệu";
                }

                pn = new AccordionPane();
                pn.ID = "Pane" + i;
                pn.HeaderContainer.Controls.Add(lbTitle);
                pn.ContentContainer.Controls.Add(lbContent);

                acrVideo.Panes.Add(pn);
                lbContent.Text = strHTML_Content;

            }
        }
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}